/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package mp.weixin.WXpublic;

import java.util.Date;

/**
 *
 * @author 王仲秋
 */
public abstract class BaseSendMessage {

    public BaseSendMessage(){}
    public BaseSendMessage(BaseReceiveMessage brm) {
        this.createTime = new Date();
        this.fromUserName = brm.getToUserName();
        this.toUserName = brm.getFromUserName();
    }
    private String toUserName;
    private String fromUserName;
    private Date createTime;

    public String getToUserName() {
        return toUserName;
    }

    public void setToUserName(String toUserName) {
        this.toUserName = toUserName;
    }

    public String getFromUserName() {
        return fromUserName;
    }

    public void setFromUserName(String fromUserName) {
        this.fromUserName = fromUserName;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public abstract SendTypeEnum getMsgType();

    public enum SendTypeEnum {

        /**
         * 文本消息
         */
        TEXT("文本", "text"),
        /**
         * 图片消息
         */
        IMAGE("图片", "image"),
        /**
         * 语音消息
         */
        VOICE("语音", "voice"),
        /**
         * 视频消息
         */
        VIDEO("视频", "video"),
        /**
         * 小视频消息
         */
        MUSIC("音乐", "music"),
        /**
         * 图文消息
         */
        NEWS("图文", "news"),
        /**
         * 将会话转给客服
         */
        TRANSFER_CUSTOMER_SERVICE("转接客服","transfer_customer_service");
        private final String desc;
        private final String type;

        SendTypeEnum(String desc, String type) {
            this.desc = desc;
            this.type = type;
        }

        public String getDesc() {
            return this.desc;
        }

        public String getType() {
            return type;
        }

        /**
         * 保证这个方法的正常使用必须保证 定义枚举对象的时候 枚举对象的名称是全大写 且 type属性转换成大写的时候 与枚举的对象名称一致
         *
         * @param type
         * @return
         */
        public static SendTypeEnum getEnumByType(String type) {
            return SendTypeEnum.valueOf(type.toUpperCase());
        }
    }

    public abstract String toWeiXinMessageXMLString();
}
